import javax.naming.ldap.PagedResultsControl;

import edu.uci.ics.crawler4j.crawler.CrawlConfig;
import edu.uci.ics.crawler4j.crawler.CrawlController;
import edu.uci.ics.crawler4j.fetcher.PageFetcher;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer;

public class Controller {
        public static void main(String[] args) throws Exception {
        		String crawlStorageFolder = "C:\\data\\crawl\\root";
                int numberOfCrawlers = 1;

                CrawlConfig config = new CrawlConfig();
                config.setCrawlStorageFolder(crawlStorageFolder);
                config.setMaxDownloadSize(10000);
                config.setPolitenessDelay(500);
                config.setIncludeHttpsPages(true);
                
                /*
                 * Instantiate the controller for this crawl.
                 */
                PageFetcher pageFetcher = new MyFetcher(config);
                RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
                RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
                CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer);
                /*
                 * For each crawl, you need to add some seed urls. These are the first
                 * URLs that are fetched and then the crawler starts following links
                 * which are found in these pages
                 */
                //	http://www.ics.uci.edu/
//                controller.addSeed("http://www.ics.uci.edu/~welling/");
//                controller.addSeed("http://www.ics.uci.edu/~lopes/");
//                controller.addSeed("http://www.ics.uci.edu/");
//                controller.addSeed("http://www.timliao.com/");
//                controller.addSeed("http://www.ipeen.com.tw/");
                controller.addSeed("https://www.ptt.cc/bbs/MacShop/index.html");
                /*
                 * Start the crawl. This is a blocking operation, meaning that your code
                 * will reach the line after this only when crawling is finished.
                 */
                controller.start(MyCrawler.class, numberOfCrawlers);    
        }
}
